#ifndef __COMBINATION_IO_H__
#define __COMBINATION_IO_H__ 1

#include "sample_io.h"
#include "codec.h"

class CCombinationIO : public ISampleIO
{
public:
	CCombinationIO(ISampleIO *pReadIO, ISampleIO *pWriteIO);
	virtual ~CCombinationIO();

	/* START methods inherited by ISampleIO */
	virtual int init(CPropertiesReader *pConfig);
	virtual int destroy();

	virtual int read(void** pData, EAction& pAction, int pTimeout = 1000);
	virtual int write(void* pData, const EAction& pAction, int pLength);

	virtual NAudioFormats::SStreamInfo getStreamInfo();
	/* END methods inherited by ISampleIO */

private:
	ISampleIO *mReadIO;
	ISampleIO *mWriteIO;

	bool mRecoding;
	ICodec* mReadCodec;
	ICodec* mWriteCodec;
	double* mDoubleSampleBuf;
	int mDoubleSampleCount;
	char* mByteBuf;
	int mByteCount;

	CCombinationIO(const CCombinationIO& );
	CCombinationIO& operator=(const CCombinationIO& );

	/**
	 * @param pSampleLength Count of double samples. If pSampleLength <= 0
	 *        then the intern buffer will be freed.
	 */
	double* getDoubleBuffer(int pSampleLength);
	void* getByteBuffer(int pByteLength);
};

#endif /* __COMBINATION_IO_H__ */

